## This script assumes that the working directory is the top level of the archive

home <- getwd()
library(foreign)
source(paste(home,"/pta/scripts/runBigMahal_PTA.R",sep=""))

HRA <- "iccpr"

## All observation matching
if(!file.exists(paste(home,"/pta/madedata/mahmatches_",HRA,"/pta.dta",sep=""))){
  runBigMahal_PTA(HRA=HRA, 
    inData=paste(home,"/pta/madedata/",HRA,"RatEpisodeDat.dta",sep=""),
    outData=paste(home,"/pta/madedata/mahmatches_",HRA,"pta.dta",sep=""))
}


## if HRAname_1==1 & HRAname_2==0 (looking at decisions by ratifiers to sign with other countries that have not yet ratified)
if(!file.exists(paste(home,"/pta/madedata/mahmatches_",HRA,"pta_Ratifiers.dta",sep=""))){
  runBigMahal_PTA(HRA=HRA, 
    inData=paste(home,"/pta/madedata/",HRA,"RatEpisodeDat_Ratifiers.dta",sep=""),
    outData=paste(home,"/pta/madedata/mahmatches_",HRA,"pta_Ratifiers.dta",sep=""))
}


## if HRAname_1==1 (looking at decisions by ratifiers to sign with other countries)
if(!file.exists(paste(home,"/pta/madedata/mahmatches_",HRA,"pta_Ratifiers1.dta",sep=""))){
  runBigMahal_PTA(HRA=HRA, 
    inData=paste(home,"/pta/madedata/",HRA,"RatEpisodeDat_Ratifiers1.dta",sep=""),
    outData=paste(home,"/pta/madedata/mahmatches_",HRA,"pta_Ratifiers1.dta",sep=""))
}
